import React      from 'react'
import { Route, Redirect, Switch, Link } from 'react-router-dom'
// 页面
import ProductList    from './index/index.jsx'
import ProductSave    from './index/save.jsx'
import ProductDetail  from './index/detail.jsx'
import CategoryList   from './category/index.jsx'
import CategoryAdd   from './category/add.jsx'
export default class ProductRouter extends React.Component {
  render () {
    return (
      <Switch>
        <Route path="/product/index" component={ProductList}/>
        {/* 加了问号，表示这个id是可选的，有没有id都进这个组件 */}
        <Route path="/product/save/:pid?" component={ProductSave}/>
        <Route path="/product/detail/:pid" component={ProductDetail}/>
        <Route path="/product-category/index/:categoryId?" component={CategoryList}/>
        <Route path="/product-category/add" component={CategoryAdd}/>
        <Redirect from="/product" to="/product/index"></Redirect>
        <Redirect from="/product-category" to="/product-category/index"></Redirect>
      </Switch>
    );
  }
}